<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>ec: ec::TcpClient Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">ec
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>ec</b></li><li class="navelem"><a class="el" href="classec_1_1TcpClient.html">TcpClient</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classec_1_1TcpClient-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">ec::TcpClient Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>客户端TCP连接  
 <a href="classec_1_1TcpClient.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="tcpClient_8h_source.html">tcpClient.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for ec::TcpClient:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classec_1_1TcpClient.png" usemap="#ec::TcpClient_map" alt=""/>
  <map id="ec::TcpClient_map" name="ec::TcpClient_map">
<area href="classec_1_1TcpSocket.html" title="TCP连接基类 " alt="ec::TcpSocket" shape="rect" coords="0,0,91,24"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aeddd87eefbaf668137546b0232291d8a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeddd87eefbaf668137546b0232291d8a"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>TcpClient</b> (const <a class="el" href="classec_1_1Loop.html">ec::Loop</a> &amp;loop)</td></tr>
<tr class="separator:aeddd87eefbaf668137546b0232291d8a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aea5214d714c2c79d05bf0ff224b19e10"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpClient.html#aea5214d714c2c79d05bf0ff224b19e10">isConnected</a> () const </td></tr>
<tr class="separator:aea5214d714c2c79d05bf0ff224b19e10"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aced7a41792c93f2b8515f2b30b265a3f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpClient.html#aced7a41792c93f2b8515f2b30b265a3f">connect</a> (const char *ip, uint16_t port)</td></tr>
<tr class="memdesc:aced7a41792c93f2b8515f2b30b265a3f"><td class="mdescLeft">&#160;</td><td class="mdescRight">连接服务器  <a href="#aced7a41792c93f2b8515f2b30b265a3f">More...</a><br/></td></tr>
<tr class="separator:aced7a41792c93f2b8515f2b30b265a3f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classec_1_1TcpSocket"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classec_1_1TcpSocket')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classec_1_1TcpSocket.html">ec::TcpSocket</a></td></tr>
<tr class="memitem:a75615a2cb729bf1e11f7bf9414dedb6e inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#a75615a2cb729bf1e11f7bf9414dedb6e">isInited</a> () const </td></tr>
<tr class="separator:a75615a2cb729bf1e11f7bf9414dedb6e inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5612ba87be272ed6dcc50d3dd097070c inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">SocketFd&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#a5612ba87be272ed6dcc50d3dd097070c">getSocket</a> () const </td></tr>
<tr class="separator:a5612ba87be272ed6dcc50d3dd097070c inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac2b55cbb75000a218b3c1d83c1365611 inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#ac2b55cbb75000a218b3c1d83c1365611">getAddr</a> (struct sockaddr_in *dest, uint32_t size) const </td></tr>
<tr class="separator:ac2b55cbb75000a218b3c1d83c1365611 inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af9e2fdbb732d93537e2867eeebc34ab2 inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#af9e2fdbb732d93537e2867eeebc34ab2">send</a> (const char *data, uint32_t size)</td></tr>
<tr class="memdesc:af9e2fdbb732d93537e2867eeebc34ab2 inherit pub_methods_classec_1_1TcpSocket"><td class="mdescLeft">&#160;</td><td class="mdescRight">发送数据  <a href="#af9e2fdbb732d93537e2867eeebc34ab2">More...</a><br/></td></tr>
<tr class="separator:af9e2fdbb732d93537e2867eeebc34ab2 inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aac8cfc7de1d70f850ec304a40ef814a6 inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#aac8cfc7de1d70f850ec304a40ef814a6">close</a> (bool waiting=true)</td></tr>
<tr class="memdesc:aac8cfc7de1d70f850ec304a40ef814a6 inherit pub_methods_classec_1_1TcpSocket"><td class="mdescLeft">&#160;</td><td class="mdescRight">关闭连接  <a href="#aac8cfc7de1d70f850ec304a40ef814a6">More...</a><br/></td></tr>
<tr class="separator:aac8cfc7de1d70f850ec304a40ef814a6 inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a73baa70135fad8207968cfc2c7c6fe2a inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#a73baa70135fad8207968cfc2c7c6fe2a">getInputBufferLength</a> () const </td></tr>
<tr class="separator:a73baa70135fad8207968cfc2c7c6fe2a inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a50a9ce465e5c0e0c20fe63f99cc294af inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">const uint8_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#a50a9ce465e5c0e0c20fe63f99cc294af">viewInputBuffer</a> (uint32_t size) const </td></tr>
<tr class="separator:a50a9ce465e5c0e0c20fe63f99cc294af inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a64a402951553c83c1ba6be46fcf642d0 inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#a64a402951553c83c1ba6be46fcf642d0">readInputBuffer</a> (uint8_t *dest, uint32_t size)</td></tr>
<tr class="separator:a64a402951553c83c1ba6be46fcf642d0 inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a55626e2cba2d193b4aa04ee0fc8a197e inherit pub_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpSocket.html#a55626e2cba2d193b4aa04ee0fc8a197e">clearInputBuffer</a> ()</td></tr>
<tr class="separator:a55626e2cba2d193b4aa04ee0fc8a197e inherit pub_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a5fb6c3ed5388a03de459b6fc233c82ea"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpClient.html#a5fb6c3ed5388a03de459b6fc233c82ea">onRead</a> ()</td></tr>
<tr class="separator:a5fb6c3ed5388a03de459b6fc233c82ea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad528b3c242a0f694d5a0bd1f92a614b8"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpClient.html#ad528b3c242a0f694d5a0bd1f92a614b8">onDisconnected</a> ()</td></tr>
<tr class="separator:ad528b3c242a0f694d5a0bd1f92a614b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adaedc4e778e2de8fca42217e305ed0da"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpClient.html#adaedc4e778e2de8fca42217e305ed0da">onConnected</a> (int error)</td></tr>
<tr class="memdesc:adaedc4e778e2de8fca42217e305ed0da"><td class="mdescLeft">&#160;</td><td class="mdescRight">连接成功时处理接口  <a href="#adaedc4e778e2de8fca42217e305ed0da">More...</a><br/></td></tr>
<tr class="separator:adaedc4e778e2de8fca42217e305ed0da"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pro_methods_classec_1_1TcpSocket"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_classec_1_1TcpSocket')"><img src="closed.png" alt="-"/>&#160;Protected Member Functions inherited from <a class="el" href="classec_1_1TcpSocket.html">ec::TcpSocket</a></td></tr>
<tr class="memitem:ae5053578ebd24aac2aaf6e7a697a71d6 inherit pro_methods_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae5053578ebd24aac2aaf6e7a697a71d6"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>checkClosing</b> ()</td></tr>
<tr class="separator:ae5053578ebd24aac2aaf6e7a697a71d6 inherit pro_methods_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pro_attribs_classec_1_1TcpSocket"><td colspan="2" onclick="javascript:toggleInherit('pro_attribs_classec_1_1TcpSocket')"><img src="closed.png" alt="-"/>&#160;Protected Attributes inherited from <a class="el" href="classec_1_1TcpSocket.html">ec::TcpSocket</a></td></tr>
<tr class="memitem:a13725375b3f583451cc71e907ca9e919 inherit pro_attribs_classec_1_1TcpSocket"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a13725375b3f583451cc71e907ca9e919"></a>
struct bufferevent *&#160;</td><td class="memItemRight" valign="bottom"><b>_bev</b></td></tr>
<tr class="separator:a13725375b3f583451cc71e907ca9e919 inherit pro_attribs_classec_1_1TcpSocket"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>客户端TCP连接 </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="aced7a41792c93f2b8515f2b30b265a3f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ec::TcpClient::connect </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>ip</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>port</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>连接服务器 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ip</td><td>服务器IP地址 </td></tr>
    <tr><td class="paramname">port</td><td>服务器监听端口 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>返回是否成功 </dd></dl>

</div>
</div>
<a class="anchor" id="aea5214d714c2c79d05bf0ff224b19e10"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool ec::TcpClient::isConnected </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>是否已成功连接 </p>

</div>
</div>
<a class="anchor" id="adaedc4e778e2de8fca42217e305ed0da"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpClient::onConnected </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>error</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>连接成功时处理接口 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">error</td><td>连接错误码，0表示成功 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ad528b3c242a0f694d5a0bd1f92a614b8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpClient::onDisconnected </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>连接断开时处理接口 </p>

</div>
</div>
<a class="anchor" id="a5fb6c3ed5388a03de459b6fc233c82ea"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpClient::onRead </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>有数据可读时处理接口 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>include/ec/<a class="el" href="tcpClient_8h_source.html">tcpClient.h</a></li>
<li>src/tcpClient.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Tue Jul 12 2016 14:15:09 for ec by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
